#ifndef _S_FREERTOS_EVENT_H_
#define _S_FREERTOS_EVENT_H_

#include "FreeRTOS.h"
#include "queue.h"
#include "cmsis_os.h"

typedef enum
{
	s_freeRTOS_event_ok = 0,
	s_freeRTOS_event_evtData_tooLong,
	s_freeRTOS_event_queue_null,
	s_freeRTOS_event_noEvent,
	s_freeRTOS_event_mallocfailed,
}s_freeRTOS_event_state;

typedef struct
{
	QueueHandle_t eventHandle;
	unsigned short eventDeepth;
	unsigned short eventWaitTime;
	unsigned short eventDataThresholdLen;
}s_freeRTOS_event_t;

typedef enum
{
	s_freeRTOS_event_default_evt = 0,
	s_freeRTOS_event_sysUart_evt,
	s_freeRTOS_event_userUart_evt,
	s_freeRTOS_event_onboardbleUart_evt,
	s_freeRTOS_event_button_irq_evt,
	s_freeRTOS_event_notify_irq_evt,
	s_freeRTOS_event_notify_irq_out_evt,

	s_freeRTOS_event_dataUpload_evt,
	s_freeRTOS_event_getUSB_evt,
	s_freeRTOS_event_getUART_evt,
}s_freeRTOS_event_type;

typedef struct
{
	s_freeRTOS_event_type type;
	unsigned char *data;
	unsigned short len;
	unsigned char para;
}s_freeRTOS_event_data;

extern s_freeRTOS_event_t s_freeRTOS_event_init(unsigned short event_deepth, \
						unsigned short normal_waitTime, unsigned short event_data_threshold);
extern s_freeRTOS_event_state s_freeRTOS_event_enqueue(s_freeRTOS_event_t *event_t, \
							s_freeRTOS_event_type type, \
							unsigned char *data, unsigned short len, unsigned char para);
extern s_freeRTOS_event_state s_freeRTOS_event_enqueueFromISR(s_freeRTOS_event_t *event_t, \
							s_freeRTOS_event_type type, \
							unsigned char *data, unsigned short len, unsigned char para);
extern s_freeRTOS_event_state s_freeRTOS_event_dequeue(s_freeRTOS_event_t *event_t, \
													s_freeRTOS_event_data *que);
extern s_freeRTOS_event_state s_freeRTOS_event_dequeueFromISR(s_freeRTOS_event_t *event_t, \
													s_freeRTOS_event_data *que);

#endif
